//
//  RentRuleView.m
//  RentTable
//
//  Created by mac on 2024/11/30.
//

#import "RentRuleView.h"

@interface RentRuleView()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UIView *leftDevidView;
@property (nonatomic, strong) UIView *rightDevidView;

@property (nonatomic, strong) UILabel *ruleLabel;

@end

@implementation RentRuleView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self == [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    UIView *leftDevidView = [UIView new];
    leftDevidView.backgroundColor = myRGBHex(0xCCCCCC);
    [self addSubview:leftDevidView];
    self.leftDevidView = leftDevidView;
    
    UIView *rightDevidView = [UIView new];
    rightDevidView.backgroundColor = myRGBHex(0xCCCCCC);
    [self addSubview:rightDevidView];
    self.rightDevidView = rightDevidView;
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.text = @"租赁规则";
    self.nameLabel.font = [UIFont pingFangSCMediumWithSize:14];
    self.nameLabel.textColor = myRGBHex(0x666666);
    [self addSubview:self.nameLabel];
    
    
    self.ruleLabel = [[UILabel alloc] init];
    self.ruleLabel.text = @"租期是从用户签收日次日起计算，（正常是按快递到货，次日由于用户原因延误签收，时间延误时间计入租期内）例如：用户您选择的租期是3号到9号（计费时间为七天），但是4号快递才送到货给您签收，则从5号起算租期，到期后，可相应顺延2.5天再归还寄回（及时2号中午12点前寄回设备），寄回时间以快递显示的揽收时间为准。";
    self.ruleLabel.font = [UIFont pingFangSCRegularWithSize:14];
    self.ruleLabel.textColor = myRGBHex(0x999999);
    self.ruleLabel.numberOfLines = 0;
    [self addSubview:self.ruleLabel];
    
    [self setupLayout];
}

- (void)setupLayout {
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(2);
        make.height.mas_equalTo(18);
    }];
    
    [self.leftDevidView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameLabel.mas_centerY);
        make.trailing.equalTo(self.nameLabel.mas_leading).offset(-16);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(50);
    }];
    
    [self.rightDevidView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameLabel.mas_centerY);
        make.leading.equalTo(self.nameLabel.mas_trailing).offset(16);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(50);
    }];
    
    [self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(16);
        make.trailing.mas_equalTo(-16);
        make.top.equalTo(self.nameLabel.mas_bottom).offset(8);
    }];
}

@end
